Changing Hashcodes: Objects, Intialisation, and Collections
نویسندگان
چکیده
Java requires objects’ hashcodes to be consistent with object equality, and to change only when an object’s equality changes. Equality dependent Java collections impose a stricter contextual contract on an objects’ equality, comparability, and hashcode methods: that they cannot change while those objects are in collections. By dynamically profiling 30 Java applications, we have determined that programmers use quite sophisticated techniques to ensure their objects meet these contracts. Some objects are immutable; some objects are initially mutable, but become immutable when inserted into equalitydependent collections; some objects continue to change when inserted into equality dependent collections — but those changes do not affect equality or hashcodes. On the other hand, some objects inserted into collections that do not depend on object equality, hashcodes, or comparisons will contine to change all their state, including equality and hashcode, while they are in those collections. Programmers and educators can use these results to ensure they (or their students) are aware of these subtle conditional contracts underlying Java’s collection design. These results can also guide language designers adding support for collections, relations, or equality: in particular; while immutablility suffices for many cases, it does not cover all of them.
منابع مشابه
تحلیل بحران برپایۀ سنجش عوامل مؤثر بر خوردگی فعال و ارزیابی بحران در مجموعههای برنزی باستانی
Recently risk assessment and management in cultural-historical collections is one of the important subjects in the field of preventive conservation research. Different methods and aspects of are used and studied in the field of risk assessment in archaeological sites and collections and significant results are achieved and published in last decades. One of the types of archaeological collection...
متن کاملStatistical Background Modeling Based on Velocity and Orientation of Moving Objects
Background modeling is an important step in moving object detection and tracking. In this paper, we propose a new statistical approach in which, a sequence of frames are selected according to velocity and direction of some moving objects and then an initial background is modeled, based on the detection of gray pixel's value changes. To have used this sequence of frames, no estimator or distribu...
متن کاملEfficient Cellular Automata for 2D/3D Free-form Modeling
This paper presents an approach for efficiently simulating highly deformable 2D substances undergoing viscoplastic deformations in real time. The user deals with objects in the same way as clay works. Based on the work of Y. Takai and H. Arata, we suggest a new approach for the computation of repartition rules. We use a discrete 2D space in which each pixel is given a certain amount of clay at ...
متن کاملمستند نگاری ظروف سفالی گِلابه ای منقوش رنگارنگ روی زمینه سفید(موزه بنیاد تهران)
Cultural Institute of Tehran’s Bonyad Museums includes the most exquisite collections in separate sections. The pottery vault is one part of this museum. The mentioned collection is one of the most unique collections existing in the country. There are many pottery wares in this collection, whose production centers and dates are not clearly known. In the present research, six samples of polychro...
متن کاملMiddleware for Building Ubiquitous Computing Applications Using Distributed Objects
Ubiquitous systems are characterized by multi-fold complexity, stemming mainly from the vast number of possible interactions between many heterogeneous objects and services. Devices ranging from simple everyday objects populated with sensing, actuating and communication capabilities to complex computer systems, mobile or not, are treated as reusable “components” of a dynamically changing physic...
متن کامل